<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport"   content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <script type="text/javascript" src="js/toolLibrary/Zepto-1.2.0-min.js"></script>
    <script type="text/javascript" src="js/ajax.js"></script>
    <script type="text/javascript" src="js/pageFlex.js"></script>
    <link rel="stylesheet" href="css/index.css">
</head>
<body>
    <div id="header">
        <div class="simple_showDiv">
            <div class="simple_label">发货单位</div>
            <div class="simple_showInput" id="sendUnit">中车株洲电机有限公司</div>
        </div>
        <div class="simple_showDiv">
            <div class="simple_label">发运日期</div>
            <div class="simple_showInput" id="sendDate"></div>
        </div>
        <div class="simple_showDiv simple_centerMargin">
            <div class="simple_label">发货人</div>
            <div class="simple_showInput" id="sendPerson"></div>
        </div>
        <div class="simple_showDiv simple_centerMargin">
            <div class="simple_label">发运地址</div>
            <div class="simple_showInput" id="sendAddress"></div>
        </div>
        <div class="simple_showDiv">
            <div class="simple_label">出库单号</div>
            <div class="simple_showInput" id="outBillCode" ></div>
        </div>
    </div>
    <table id="content" border="1" cellpadding="0" cellspacing="0">
        <tr style="width: 5%">
            <th style="width: 10%">序号</th>
            <th style="width: 25%">物料编码</th>
            <th style="width: 45%">物料名称</th>
            <th style="width: 20%">数量</th>
<!--            <th style="width: 20%">序列号</th>-->
        </tr>
    </table>
<!--    <div id="footer">-->
<!--        <div class="simple_showDiv">-->
<!--            <div class="simple_label">收货单位</div>-->
<!--            <div class="simple_showInput" id="acceptUnit"></div>-->
<!--        </div>-->
<!--        <div class="simple_showDiv">-->
<!--            <div class="simple_label">收货地址</div>-->
<!--            <div class="simple_showInput" id="acceptAddress"></div>-->
<!--        </div>-->
<!--        <div class="simple_showDiv simple_centerMargin">-->
<!--            <div class="simple_label">收货人</div>-->
<!--            <div class="simple_showInput" id="acceptPerson"></div>-->
<!--        </div>-->
<!--        <div class="simple_showDiv simple_centerMargin">-->
<!--            <div class="simple_label">联系方式</div>-->
<!--            <div class="simple_showInput" id="acceptContact"></div>-->
<!--        </div>-->
<!--    </div>-->
    <div class="clickButton clickButton_center">签名</div>
</body>
<script type="text/javascript">
    $(window).on("load",function(){
        if(window.location.search == ""){
            window.location.href = "./404.html";
        }else {
            let outBillCode = window.location.search.split('=')[1];
            ajax({
                    method:"get",
                    //url:"http://192.168.10.200:8080/relay/out/bills",
					url:"http://172.20.10.4:8913/wms/out/master/sign/detail",
                    data:{
                        billNo:outBillCode
                    },
                    async : true,
                    success:function(resp){
                        console.log(resp);
                        let obj = $.parseJSON(resp);
                        let data = obj.data.details;
                        if(data.length == 0){
                            alert("该出库单无数据，请检查二维码后再次扫描！");
                            setTimeout(function(){
                                window.location.href = "./404.html";
                            },1000)
                        }else{
                            for (const name in obj.data) {
                                if(name != 'details'){
                                    $('#' + name).text(obj.data[name]);
                                }
                            }
                            for (let i = 0; i < data.length ; i++) {
                                let $tr = $("<tr></tr>");
                                $($tr).append($("<th>"+ i +"</th>"));
                                $tr.append($("<th>"+ data[i].itemCode +"</th>"));
                                $tr.append($("<th>"+ data[i].itemName +"</th>"));
                                $tr.append($("<th>"+ data[i].deliveryQuantity +"</th>"));
                                // $tr.append($("<th>"+ data[i].sn +"</th>"));
                                $('#content').append($tr);
                            }
                        }
                    },
                    error:function(error){
                        setTimeout(function(){
                            window.location.href = "./404.html";
                        },1000)
                    }
                }
            );
        }
    })
        $(".clickButton").on('click',function () {
            window.location.href="./pages/signature.html"+window.location.search;
        })
</script>
</html>
